import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/LoginView.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/RegisterView.vue')
  },
  {
    path: '/home/dashboard',
    name: 'Dashboard',
    component: () => import('@/views/Dashboard.vue'),
    children: [
      {
        path: '/home',
        name: 'Home',
        component: Home,
        meta: { title: '首页', icon: ['fas', 'house-user'], top: true }
      },
      {
        path: '/info',
        name: 'Info',
        component: () => import('@/views/Info.vue')
      },

      // 系统设置
      {
        path: '/system-settings',
        name: 'SystemSettings',
        meta: { 
          title: '系统设置', 
          icon: ['fas', 'gear'],
          top: true
        },
        children: [
          {
            path: 'basic-settings',
            name: 'BasicSettings',
            component: () => import('@/views/system-settings/BasicSettings.vue'),
            meta: { 
              title: '基本设置', 
              icon: ['fas', 'sliders'] 
            }
          },
          {
            path: 'parameter-config',
            name: 'ParameterConfig',
            component: () => import('@/views/system-settings/ParameterConfig.vue'),
            meta: { 
              title: '参数配置', 
              icon: ['fas', 'wrench'] 
            }
          },
          {
            path: 'payment-settings',
            name: 'PaymentSettings',
            component: () => import('@/views/system-settings/PaymentSettings.vue'),
            meta: { 
              title: '支付设置', 
              icon: ['fas', 'credit-card'] 
            }
          },
          {
            path: 'notification-settings',
            name: 'NotificationSettings',
            component: () => import('@/views/system-settings/NotificationSettings.vue'),
            meta: { 
              title: '通知设置', 
              icon: ['fas', 'bell'] 
            }
          }
        ]
      },

      // 用户管理
      {
        path: '/user-management',
        name: 'UserManagement',
        meta: { 
          title: '用户管理', 
          icon: ['fas', 'users'],
          top: true
        },
        children: [
          {
            path: 'user-list',
            name: 'UserList',
            component: () => import('@/views/user-management/UserList.vue'),
            meta: { 
              title: '用户列表', 
              icon: ['fas', 'list'] 
            }
          },
          {
            path: 'user-group',
            name: 'UserGroup',
            component: () => import('@/views/user-management/UserGroup.vue'),
            meta: { 
              title: '用户组管理', 
              icon: ['fas', 'users-between-lines'] 
            }
          },
          {
            path: 'login-logs',
            name: 'LoginLogs',
            component: () => import('@/views/user-management/LoginLogs.vue'),
            meta: { 
              title: '登录日志', 
              icon: ['fas', 'right-to-bracket'] 
            }
          },
          {
            path: 'operation-logs',
            name: 'OperationLogs',
            component: () => import('@/views/user-management/OperationLogs.vue'),
            meta: { 
              title: '操作日志', 
              icon: ['fas', 'clipboard-list'] 
            }
          }
        ]
      },

      // 角色权限
      {
        path: '/role-permission',
        name: 'RolePermission',
        meta: { 
          title: '角色权限', 
          icon: ['fas', 'user-shield'],
          top: true
        },
        children: [
          {
            path: 'role-management',
            name: 'RoleManagement',
            component: () => import('@/views/role-permission/RoleManagement.vue'),
            meta: { 
              title: '角色管理', 
              icon: ['fas', 'id-card'] 
            }
          },
          {
            path: 'permission-config',
            name: 'PermissionConfig',
            component: () => import('@/views/role-permission/PermissionConfig.vue'),
            meta: { 
              title: '权限配置', 
              icon: ['fas', 'key'] 
            }
          },
          {
            path: 'menu-management',
            name: 'MenuManagement',
            component: () => import('@/views/role-permission/MenuManagement.vue'),
            meta: { 
              title: '菜单管理', 
              icon: ['fas', 'bars'] 
            }
          },
          {
            path: 'api-permission',
            name: 'ApiPermission',
            component: () => import('@/views/role-permission/ApiPermission.vue'),
            meta: { 
              title: '接口权限', 
              icon: ['fas', 'plug'] 
            }
          }
        ]
      },
      
      // 部门管理
      {
        path: '/department-management',
        name: 'DepartmentManagement',
        meta: { 
          title: '部门管理', 
          icon: ['fas', 'sitemap'],
          top: true
        },
        children: [
          {
            path: 'department-structure',
            name: 'DepartmentStructure',
            component: () => import('@/views/department-management/DepartmentStructure.vue'),
            meta: { 
              title: '部门结构', 
              icon: ['fas', 'diagram-project'] 
            }
          },
          {
            path: 'position-management',
            name: 'PositionManagement',
            component: () => import('@/views/department-management/PositionManagement.vue'),
            meta: { 
              title: '岗位管理', 
              icon: ['fas', 'briefcase'] 
            }
          },
          {
            path: 'personnel-assignment',
            name: 'PersonnelAssignment',
            component: () => import('@/views/department-management/PersonnelAssignment.vue'),
            meta: { 
              title: '人员分配', 
              icon: ['fas', 'user-plus'] 
            }
          }
        ]
      },
      
      // 系统工具
      {
        path: '/system-tools',
        name: 'SystemTools',
        meta: { 
          title: '系统工具', 
          icon: ['fas', 'screwdriver-wrench'],
          top: true
        },
        children: [
          {
            path: 'data-backup',
            name: 'DataBackup',
            component: () => import('@/views/system-tools/DataBackup.vue'),
            meta: { 
              title: '数据备份', 
              icon: ['fas', 'database'] 
            }
          },
          {
            path: 'cache-management',
            name: 'CacheManagement',
            component: () => import('@/views/system-tools/CacheManagement.vue'),
            meta: { 
              title: '缓存管理', 
              icon: ['fas', 'memory'] 
            }
          },
          {
            path: 'system-update',
            name: 'SystemUpdate',
            component: () => import('@/views/system-tools/SystemUpdate.vue'),
            meta: { 
              title: '系统更新', 
              icon: ['fas', 'arrow-up-from-bracket'] 
            }
          },
          {
            path: 'task-scheduling',
            name: 'TaskScheduling',
            component: () => import('@/views/system-tools/TaskScheduling.vue'),
            meta: { 
              title: '任务调度', 
              icon: ['fas', 'clock'] 
            }
          }
        ]
      },
      
      // 开发工具
      {
        path: '/development-tools',
        name: 'DevelopmentTools',
        meta: { 
          title: '开发工具', 
          icon: ['fas', 'code'],
          top: true
        },
        children: [
          {
            path: 'api-management',
            name: 'ApiManagement',
            component: () => import('@/views/development-tools/ApiManagement.vue'),
            meta: { 
              title: 'API管理', 
              icon: ['fas', 'api'] 
            }
          },
          {
            path: 'code-generation',
            name: 'CodeGeneration',
            component: () => import('@/views/development-tools/CodeGeneration.vue'),
            meta: { 
              title: '代码生成', 
              icon: ['fas', 'file-code'] 
            }
          },
          {
            path: 'api-testing',
            name: 'ApiTesting',
            component: () => import('@/views/development-tools/ApiTesting.vue'),
            meta: { 
              title: '接口测试', 
              icon: ['fas', 'vial'] 
            }
          },
          {
            path: 'log-viewer',
            name: 'LogViewer',
            component: () => import('@/views/development-tools/LogViewer.vue'),
            meta: { 
              title: '日志查看', 
              icon: ['fas', 'file-lines'] 
            }
          }
        ]
      },
      
      // 第三方服务
      {
        path: '/third-party-services',
        name: 'ThirdPartyServices',
        meta: { 
          title: '第三方服务', 
          icon: ['fas', 'plug'],
          top: true
        },
        children: [
          {
            path: 'payment-integration',
            name: 'PaymentIntegration',
            component: () => import('@/views/third-party-services/PaymentIntegration.vue'),
            meta: { 
              title: '支付集成', 
              icon: ['fas', 'money-bill-transfer'] 
            }
          },
          {
            path: 'sms-service',
            name: 'SmsService',
            component: () => import('@/views/third-party-services/SmsService.vue'),
            meta: { 
              title: '短信服务', 
              icon: ['fas', 'comment-sms'] 
            }
          },
          {
            path: 'map-service',
            name: 'MapService',
            component: () => import('@/views/third-party-services/MapService.vue'),
            meta: { 
              title: '地图服务', 
              icon: ['fas', 'map-location-dot'] 
            }
          },
          {
            path: 'social-login',
            name: 'SocialLogin',
            component: () => import('@/views/third-party-services/SocialLogin.vue'),
            meta: { 
              title: '社交登录', 
              icon: ['fas', 'share-nodes'] 
            }
          }
        ]
      },
      
      // 文档中心
      {
        path: '/documentation',
        name: 'Documentation',
        meta: { 
          title: '文档中心', 
          icon: ['fas', 'book'],
          top: true
        },
        children: [
          {
            path: 'user-manual',
            name: 'UserManual',
            component: () => import('@/views/documentation/UserManual.vue'),
            meta: { 
              title: '使用手册', 
              icon: ['fas', 'book-open'] 
            }
          },
          {
            path: 'api-documentation',
            name: 'ApiDocumentation',
            component: () => import('@/views/documentation/ApiDocumentation.vue'),
            meta: { 
              title: 'API文档', 
              icon: ['fas', 'file-code'] 
            }
          },
          {
            path: 'development-guide',
            name: 'DevelopmentGuide',
            component: () => import('@/views/documentation/DevelopmentGuide.vue'),
            meta: { 
              title: '开发指南', 
              icon: ['fas', 'code'] 
            }
          },
          {
            path: 'faq',
            name: 'FAQ',
            component: () => import('@/views/documentation/FAQ.vue'),
            meta: { 
              title: 'FAQ', 
              icon: ['fas', 'circle-question'] 
            }
          }
        ]
      },
      // 考试管理
      {
        path: '/exam',
        name: 'Exam',
        meta: { 
          title: '考试管理', 
          icon: ['fas', 'book'],
          top: true
        },
        children: [
          {
            path: 'question',
            name: 'Question',
            component: () => import('@/views/exam/Question.vue'),
            meta: { 
              title: '题库', 
              icon: ['fas', 'book-open'] 
            }
          },
          {
            path: 'examination',
            name: 'Examination',
            component: () => import('@/views/exam/Examination.vue'),
            meta: { 
              title: '考试', 
              icon: ['fas', 'file-code'] 
            }
          },
          
        ]
      },
    //   试题操作的相关路由
      {
        path: '/questionOption',
        name: 'QuestionOption',
        meta: { 
          title: '题目选项', 
          icon: ['fas', 'file-code'], 
        },
        children:[
            {
              path: 'create-question/:id?',
              name: 'CreateQuestion',
              component: () => import('@/views/exam/CreateQuestion.vue'),
              meta: { 
                title: '创建题目', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'questionPreview/:id?',
              name: 'QuestionPreview',
              component: () => import('@/views/exam/QuestionPreview.vue'),
              meta: { 
                title: '题目预览', 
                icon: ['fas', 'file-code'], 
              }
            },

        ]
      },
      //  试卷操作的相关路由
      {
        path: '/paperOption',
        name: 'PaperOption',
        meta: { 
          title: '试卷选项', 
          icon: ['fas', 'file-code'], 
        },
        children:[
            {
              path: 'create-paper/:id?',
              name: 'CreatePaper',
              component: () => import('@/views/exam/examComponents/CreatePaper.vue'),
              meta: { 
                title: '新建考试', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'paperReview/:paperId?',
              name: 'PaperReview',
              component: () => import('@/views/exam/examComponents/PaperReview.vue'),
              meta: { 
                title: '批阅试卷', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'review/:paperId?',
              name: 'Review',
              component: () => import('@/views/exam/examComponents/Review.vue'),
              meta: { 
                title: '批阅', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'reviewByQuestion/:paperId?/:questionId?',
              name: 'ReviewByQuestion',
              component: () => import('@/views/exam/examComponents/ReviewByQuestion.vue'),
              meta: { 
                title: '按照题批阅', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'detailedStatistics/:paperId?/:questionId?',
              name: 'DetailedStatistics',
              component: () => import('@/views/exam/examComponents/DetailedStatistics.vue'),
              meta: { 
                title: '详情统计', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'ExaminationStatistics/:paperId?',
              name: 'ExaminationStatistics',
              component: () => import('@/views/exam/examComponents/ExaminationStatistics.vue'),
              meta: { 
                title: '考试统计', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'updateSettings/:paperId/:source',
              name: 'UpdateSettings',
              component: () => import('@/views/exam/examComponents/UpdateSettings.vue'),
              meta: { 
                title: '发放设置', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'paperDetail/:id?',
              name: 'PaperDetail',
              component: () => import('@/views/exam/examComponents/PaperDetail.vue'),
              meta: { 
                title: '试卷详情', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'paperStore',
              name: 'PaperStore',
              component: () => import('@/views/exam/examComponents/PaperStore.vue'),
              meta: { 
                title: '试卷库', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'paperExportSettings/:mode?/:paperId?',
              name: 'PaperExportSetting',
              component: () => import('@/views/exam/examComponents/ExportSetting.vue'),
              meta: { 
                title: '试卷导出设置', 
                icon: ['fas', 'file-code'], 
              }
            },
            {
              path: 'paperStructureAnalysis/:id?',
              name: 'PaperStructureAnalysis',
              component: () => import('@/views/exam/examComponents/PaperStructureAnalysis.vue'),
              meta: { 
                title: '试卷结构分析', 
                icon: ['fas', 'file-code'], 
              }
            },
            
        ]
      },
      /*  {
        path: '/test',
        name: 'test',
         meta: { title: '测试', icon: ['fas', 'gear'],top: true  },
        children: [
          {
            path: '/test/test1',
            name: 'test1',
            meta: { title: '测试1', icon: ['fas', 'gear'], },
            component: () => import('@/views/test/Test1.vue')
          },
          {
            path: '/test/test2',
            name: 'test2',
            meta: { title: '测试2', icon: ['fas', 'gear'],  },
            component: () => import('@/views/test/Test2.vue'),
          },
          {
            path: '/test/test3',
            name: 'test3',
            meta: { title: '测试3', icon: ['fas', 'gear'],},
            component: () => import('@/views/test/Test3.vue'),
          },
          {
            path: '/test/test4',
            name: 'test4',
            meta: { title: '测试4', icon: ['fas', 'gear'], },
            component: () => import('@/views/test/Test4.vue'),
          },
          {
            path: '/test/test5',
            name: 'test5',
            meta: { title: '测试5', icon: ['fas', 'gear'], },
            component: () => import('@/views/test/Test9.vue'),
          }
          
        ]
      }, */
    ]
  }
]


const router = createRouter({
  history: createWebHistory(),
  routes
})

// router.beforeEach((to, from, next) => {
//   // console.log("to>>",to, from);
//   next()
// })

export default router